package Homework;

public class PrintLetter extends Thread{
	Object lock;
	IsChild isNum;
	int count = 64;
	
	public PrintLetter(Object lock, IsChild isNum) {
		super();
		this.lock = lock;
		this.isNum = isNum;
	}
	
	@Override
	public void run() {
		while(true){
			synchronized (lock) {
				if(isNum.getLunshu()!=0){
					if(count!=64){
						System.out.print((char)count);
						count++;					
						isNum.setLunshu(isNum.getLunshu()-1);
						try {
							sleep(100);
						} catch (InterruptedException e1) {
							e1.printStackTrace();
						}
						lock.notify();
						try {
							lock.wait();
						} catch (InterruptedException e) {
							e.printStackTrace();
						}
					}else{
						count++;
						try {
							lock.wait();
						} catch (InterruptedException e) {
							e.printStackTrace();
						}
					}
				}else{
					break;
				}
			}
		}
	}
}

		


